<template>
  <div class="log-container">
    <div class="table-container">
      <el-table :data="list" border>
        <el-table-column prop="createTimeU" label="时间">
          <template slot-scope="scope">{{ scope.row.createTimeU | dateFilter }}</template>
        </el-table-column>
        <el-table-column prop="userName" label="操作人"></el-table-column>
        <el-table-column prop="message" label="信息"></el-table-column>
      </el-table>
    </div>
    <div class="page-container">
      <el-pagination background layout="prev, pager, next" :total="total" @current-change="currentChange"></el-pagination>
    </div>
  </div>
</template>

<script>
import moment from "moment";

export default {
  filters: {
    dateFilter(el) {
      return moment(el).format("YYYY-MM-DD HH:mm:ss");
    }
  },
  data() {
    return {
      list: [],
      pageModel: {
        pageNum: 1,
        pageSize: 10,
        sortstr: "-createTimeU"
      },
      total: 0
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList() {
      const result = await this.$fetchPost("/logrecord/pagelist", {
        pageModel: {
          pageNum: this.pageModel.pageNum - 1,
          pageSize: this.pageModel.pageSize,
          sortstr: "-createTimeU"
        }
      });
      this.list = result.result.content;
      this.total = result.result.totalElements;
      console.log(result);
    },
    currentChange (e) {
      this.pageModel.pageNum = e
      this.getList()
    }
  }
};
</script>

<style lang="less">
.log-container {
  width: 100vw;
  text-align: center;
  .table-container {
    width: 90%;
    margin: 50px auto;
  }
}
</style>